package com.jnzc.ocr.rest.app.shop.controller.common;

import com.jnzc.ocr.dependencies.rest.base.BaseController;
import com.jnzc.ocr.serv.shop.consts.ShopDictConsts;
import com.jnzc.ocr.serv.system.api.SysDictApi;
import com.jnzc.ocr.serv.system.api.SysRegionApi;
import com.jnzc.ocr.serv.system.vo.DictPair;
import com.jnzc.ocr.serv.system.vo.SysRegionVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhangcm
 * @version 1.0, 2017/10/12
 */
@Api(tags = {"common - 基础数据接口"})
@RestController
@RequestMapping("/common/data")
public class CommonDataController extends BaseController {

    @Autowired
    private SysRegionApi sysRegionApi;

    @Autowired
    private SysDictApi sysDictApi;

    @ApiOperation(value = "区域")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "maxLevel", value = "最大等级(默认3)", required = false, paramType = "query")
    })
    @GetMapping("/region")
    public List<SysRegionVo> region(@RequestParam(defaultValue = "3") Integer maxLevel) {
        return sysRegionApi.list(maxLevel);
    }

    @ApiOperation(value = "公司店铺类型列表")
    @GetMapping("/companyType")
    public List<DictPair> companyType(){
        return sysDictApi.listPair(ShopDictConsts.COMPANY_TYPE);
    }
}
